﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace DosciWordPlugin.Models
{
    public class ReferenceModel
    {
        public string ID { get; set; }
        public string Type { get; set; }
        public string Author { get; set; }
        public string Year { get; set; }
        public string Title { get; set; }
        public string NumberOfPages { get; set; }
        public string Keywords { get; set; }
        public string Digest { get; set; }
        public bool IsUsed { get; set; }


        public const string MARK_NAME_PREFIX = "mark_";

        public static string GetBookmarkNameFromID(string id)
        {
            return MARK_NAME_PREFIX + id.Replace('0', 'A').
                Replace('1', 'B').
                Replace('2', 'C').
                Replace('3', 'D').
                Replace('4', 'E').
                Replace('5', 'F').
                Replace('6', 'G').
                Replace('7', 'H').
                Replace('8', 'I').
                Replace('9', 'J');
        }

        public static string GetIDFromBookmarkName(string bookmarkName)
        {
            if (!bookmarkName.StartsWith(MARK_NAME_PREFIX)) return "";

            return bookmarkName.Replace(MARK_NAME_PREFIX, "").
                Replace("A", "0").
                Replace("B", "1").
                Replace("C", "2").
                Replace("D", "3").
                Replace("E", "4").
                Replace("F", "5").
                Replace("G", "6").
                Replace("H", "7").
                Replace("I", "8").
                Replace("J", "9");
        }
    }
}
